import {createStore,applyMiddleware,compose} from 'redux'; //compose是一个增强器
import reducer from './../reducers/index';
import thunk from 'redux-thunk';
import {createLogger} from 'redux-logger';
import DevTools from './DevTools';

// const loggerMiddleware = createLogger({//创建一个日志功能的中间件

// })

// //中间件仙子有两个一个是thunk一个是logger
// const middleware = [thunk,loggerMiddleware];

// const finalCreateStore = compose(
//     applyMiddleware(...middleware),
//     DevTools.instrument()
// )(createStore); //创建一个finalCreateStore，这个内容除了原来的createStore功能以外，还增强了中间件功能以及开发工具的功能
 
// export default finalCreateStore;

const store = createStore(reducer,applyMiddleware(thunk));

export default store;


/*
import {createStore,applyMiddleware,compose} from 'redux'; //compose是一个增强器
import reducer from './../reducers/index';
import thunk from 'redux-thunk';
import {createLogger} from 'redux-logger';
import DevTools from './DevTools';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';

const persistConfig = {
    key: 'root',
    storage: storage,
  }

const persistedReducer = persistReducer(persistConfig, reducer)

export default () => {
    let store = createStore(persistedReducer,applyMiddleware(thunk,logger))
    let persistor = persistStore(store)
    return { store, persistor }
}*/